package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.admin.request.PointsApplyAuditReq;
import com.sc.nft.admin.request.PointsApplyExchangeRecordsPageReq;
import com.sc.nft.entity.vo.PointsApplyExchangeRecordsDetailsVO;
import com.sc.nft.entity.vo.PointsApplyExchangeRecordsPageVO;
import com.sc.nft.service.DaoEcologyPointsApplyExchangeRecordsService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 产品和dao关联表(MerchantUserDao)表控制层
 *
 * @author wwc
 * @since 2023-03-28 11:05:29
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("admin/dao/exchange/points")
@Api(tags = "燃料兑换审核")
public class MerchantEcologyPointsExchangeAuditController {

    private final DaoEcologyPointsApplyExchangeRecordsService daoEcologyPointsApplyExchangeRecordsService;

    @ApiOperation(value = "燃料兑换审核列表", notes = "燃料兑换审核列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    public PageResult<PointsApplyExchangeRecordsPageVO> page(@Valid @RequestBody PointsApplyExchangeRecordsPageReq pointsApplyExchangeRecordsPageReq) {
        return PageResult.success(daoEcologyPointsApplyExchangeRecordsService.page(pointsApplyExchangeRecordsPageReq.getDaoId(),pointsApplyExchangeRecordsPageReq.getApplyStatus(),
                pointsApplyExchangeRecordsPageReq.getCollectionId(),pointsApplyExchangeRecordsPageReq.getStartTime(),pointsApplyExchangeRecordsPageReq.getEndTime(),pointsApplyExchangeRecordsPageReq.toMp(),pointsApplyExchangeRecordsPageReq.getConsumeType()));
    }

    @ApiOperation(value = "燃料兑换审核", notes = "燃料兑换审核", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/audit", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result audit(@Valid @RequestBody PointsApplyAuditReq req) {
        return daoEcologyPointsApplyExchangeRecordsService.audit(req.getId(),req.getRemark(),req.getAuditStatus());
    }

    @ApiOperation(value = "燃料兑换审核详情", notes = "燃料兑换审核详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<PointsApplyExchangeRecordsDetailsVO> details(@Valid @RequestBody IdRequest idRequest) {
        return Result.success(daoEcologyPointsApplyExchangeRecordsService.details(idRequest.getId()));
    }

}
